﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;

namespace MS.InformationManagement.Presenter.ExpedienteViewer
{
    public class ExpedienteViewerPresenter : BasePresenter<IExpedienteViewerView>
    {

        #region Constructors

        public ExpedienteViewerPresenter(IExpedienteViewerView view) : base(view) {  }

        #endregion

        #region Public Methods

        public void HandleLoad()
        {
            var businessObject = new BLL.ExpedienteViewer.ExpedienteViewer();
            View.ExpedienteEntity = businessObject.GetExpediente(View.IdExpediente);
            View.TipoUbicacion = businessObject.GetTipoUbicacion();
            View.ListTomos = new BLL.TomoManagement.TomoManagement().GetListVolumeByExpedient(View.IdExpediente);
            this.HandleSearchRadicados();
            View.Show();
        }

        public void HandleUpdate()
        {
            new BLL.ExpedienteViewer.ExpedienteViewer().UpdateExpediente(View.ExpedienteEntity);
            View.ExpedienteUpdated();
        }

        public void HandleSearchRadicados()
        {
            int totalRecords;
            View.Radicados = new BLL.ExpedienteViewer.ExpedienteViewer().GetRadicadosByExpediente(View.IdExpediente, null, null, out totalRecords);
            View.TotalRecords = totalRecords;
        }

        public void HandleCreateVolume()
        {
            new BLL.TomoManagement.TomoManagement().CreateVolume(View.IdExpediente);
        }

        #endregion

    }
}
